package com.panda.common.model.enums;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author pansd
 * @Date 2025-08-01 9:33
 * @Des
 */
public enum InterfaceInfoEnum {
    OFFLINE("下线", 0),
    ONLINE("上线", 1);


    private final String text;
    private final Integer value;

    InterfaceInfoEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    public static List<Integer> getValues() {
        return Arrays.stream(InterfaceInfoEnum.values()).map(item -> item.value).collect(Collectors.toList());
    }

    public static InterfaceInfoEnum getEnumByValue(Integer value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (InterfaceInfoEnum anEnum : InterfaceInfoEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

    public Integer getValue() {
        return value;
    }
}
